import java.util.*;

public class Test4 {
    private static int counter=0;
    public static void print(int i) {
        counter++;
        Scanner sc=new Scanner(System.in);
        int a,b;
        Set set=new HashSet<String>();
        Random r=new Random();
        while(set.size()<=i){
            a=r.nextInt(101);
            b=r.nextInt(101);
            int chara=r.nextInt(2);
            if(getCharacter(chara).equals("+")&&!getAddition(a,b,chara).equals("-1")){
                set.add(getAddition(a,b,chara));
            }else if(getCharacter(chara).equals("-")&&!getSubtraction(a,b,chara).equals("-1")){
                set.add(getSubtraction(a,b,chara));
            }else {
                continue;
            }
        }
        int size=0;
        System.out.println("第"+counter+"组测试数据输出");
        Iterator<String> iterator = set.iterator();
        while(iterator.hasNext()){
            if(size==0){
                iterator.next();
            }
            size++;
            System.out.printf("%-3d: %-12s",size,iterator.next());
            if(size==i||size%6==0){
                System.out.println();
            }
        }
    }
    static String getCharacter(int chara){
        String s="";
        if(chara==0){
            s="+";
        }else if(chara==1){
            s="-";
        }
        return s;
    }
    static String getAddition(Object a, Object b, Object chara){
        String s1="";
        try{
            int a1= Integer.parseInt(String.valueOf(a));
            int b1=Integer.parseInt(String.valueOf(b));
            int chara1=Integer.parseInt(String.valueOf(chara));
            if(!getCharacter(chara1).equals("+")){
                if(getCharacter(chara1).equals("-")){
                    getSubtraction(a,b,chara);
                }else {
                    s1="计算符号出错";
                }
            }else{
                if (a1>100||a1<0||b1>100||b1<0) {
                    s1="输入超出0-100的范围";
                }else if(getCharacter(chara1).equals("+")&&a1+b1<=100) {
                    s1= a1 + getCharacter(chara1) + b1 + "=" + (a1 + b1);
                }else {
                    s1="-1";
                }
            }
        }catch (Exception e){
            System.out.print("算数的输入数据不符合要求，请输入整数类型");
        }
        return s1;
    }
    static String getSubtraction(Object a, Object b, Object chara){
        String s2="";
        try {
            int a2= Integer.parseInt(String.valueOf(a));
            int b2=Integer.parseInt(String.valueOf(b));
            int chara2=Integer.parseInt(String.valueOf(chara));
            if(!getCharacter(chara2).equals("-")){
                if(getCharacter(chara2).equals("+")){
                    getAddition(a,b,chara);
                }else {
                    s2="计算符号出错";
                }
            }else{
                if (a2>100||a2<0||b2>100||b2<0) {
                    s2="输入超出0-100的范围";
                }else if(getCharacter(chara2).equals("-")&&a2-b2>=0) {
                    s2= a2 + getCharacter(chara2) + b2 + "=" + (a2 - b2);
                }else {
                    s2="-1";
                }
            }
        }catch (Exception e){
            System.out.print("算数的输入数据不符合要求，请输入整数类型");
        }
        return s2;
    }
}
